N 1772
abstract
so far implementations of real arithmetic within logic programing
have ben nonlogical  a logical description of the behaviour of arithmetic
on actual
machines using finite precision numbers is not readily available  
using interval analysis a simple description of real arithmetic is posible
this can be translated to an implementation within prolog
as wel as having a sound logical basis the resulting system 
alows a very concise and powerful programing style and is potentialy
very eficient
logic programing aims to use sets of logical formulae as
statements in a programing language
because of many practical dificulties the ful generality of logic
canot yet be used in this way   however by restricting the
clas of formulae used to horn clauses practical and eficient
languages such as prolog are obtained
one of the main problems in logic programing is to extend this area
of practicality and eficiency to an ever wider range of formulae and 
aplications  
this paper considers such an implementation for arithmetic
to se why arithmetic as it is following implemented in prolog systems
is not logical consider the folowing example
x  067 y  045 z is xy z  030
this uses the notation of the edinburgh style prologs
for the moment we asume an underlying floating point
decimal arithmetic with two significant places
the predicate is asumes its righthand side is an arithmetic
statement computes its value and unifies the result with its lefthand side
in this case the entire sequence suceds however there are some serious 
problems
in a pure logic program the order of statements should be irelevant to
the corectnes of the result at worst termination or eficiency might be
afected  this is not true of the example above  the direction of execution
of is is strictly one way so that
y  045 z  030 z is xy
wil deliver an eror when x is found to be uninstantiated inside is
the second problem is that the answer z  030 is incorect 
the corect infinite precision answer is z  03015  this inacuracy
is caused by the finite precision implemented in the floating point
arithmetic of modern computers
it becomes very problematic to say what if anything it means when
z is bound to 030 by is  this problem is exacerbated by long sequences
of arithmetic operations where the propagation of such erors can lead the
final result to have litle or no resemblence to the corect answer
this is further clas of erors which is ilustrated by the fact that the
folowing two sequences wil both suced if the underlying arithmetic rounds
x  066 y  045 z  030 z is xy
x  067 y  045 z  030 z is xy
this means that even if some invertable form of arithmetic were devised
capable of binding x when
y  045 z  030 z is xy
it is unclear which value should be given to it
the problem then is to implement arithmetic in as logical a maner
as posible while stil making use of eficient floating point arithmetic
the solution to this problem has thre major parts
the first is to represent prologs 
arithmetic variables internaly as intervals of real numbers
so the result of z is 045067 would be to bind z to the 
open interval 030031  
this says that z lies somewhere in the interval
030  z  031 which is certainly true and probably as informative
as posible given finite precision arithmetic
note that z is not bound to the data structure 030031 this
is a hiden representation in much the same way that pointers are used
to implement logical variables in prolog but are not explicitly visible
to the user  throughout this paper brackets such as  or  wil
be used to represent open and closed intervals not prolog data structures
the second part of the solution is to translate expresions such as
z is xy2 to the relational form multiplyxyt0 multiply2zt0
note that both the  and  operators have ben translated to multiply
with parameters in a diferent order  this relational form wil be sen to 
be insensitive to which parameters are instantiated and which are not
thus providing invertibility
the third part is to provide a smal number of control predicates able
to guide the search for solutions
the resulting system is suficiently powerful to be able to
solve equations such as 0 is x21 directly
the next section gives a somewhat more formal description of arithmetic
implemented this way  section i gives examples of its use and of the
types of equations that are soluble within it  section iv compares our 
aproach here with that of other interval arithmetic systems and with
constraint networks  section v notes some posibilities for a paralel 
dataflow implementation which avoids many of the dificulties of traditional
dataflow execution
define ir to be the set of intervals over the real numbers r
so that the lower and uper bounds of each interval can be operated on as 
single entities they wil be treated as pairs of values  
each value having an atribute of being open or closed 
and an asociated number  for example the interval 031033 wil be
treated as the the pair lo 031 and hi 033  
the brackets are superscripted to minimize visual confusion when writeing 
bounds not in pairs
as wel as the usual real numbers 
 inf and inf wil be used as part of bounds
with the properties that al x mo r inf  x  inf 
the set of al uper bounds is defined as
hr x sup b  x mo r union  inf b mo  hi  ho   
and the set of lower bounds as
lr  sup b x  x mo r union  inf b mo  li  lo   
the set of al intervals is then defined by
irlr times hr
using this notation rather losely intervals wil be identified 
with the apropriate subset of the reals  for example the folowing 
identifications wil be made
03115 li 031 ho 15   x mo r 031  x  15 
infinf li inf  hi inf  r
and051inf lo 051  hi inf   x mo r 051  x 
the definition above carefuly excludes intervals such as infinf
in the interests of simplifying some of the later development
the finite arithmetic available on computers is represented by a
finite subset s of r  it is asumed that 
01 mo s  the set of intervals alowed over s is is defined as 
above for r  s might be a bounded set of integers or some more complex
set representable by floating point numbers
there is a useful maping from ir to is which asociates
with each real interval the best aproximation to it
aproxlhl prime h prime 
wherel prime mo ls l prime  l and nexist x mo lsl prime xl
h prime mo hs h prime  h and nexist x mo hsh prime xh
the ordering on the bounds is defined as folows
l  h  lh mo ir l  sup u x and h   sup v y
and xy or xy and uv
where  ho li hi lo ocur in this order and xy is the usual ordering 
on the reals extended to include inf and inf  
the ordering on the brackets is carefuly chosen so that intervals such as
3131 map to the empty set
given this definition it is easily verified that aprox gives
the smalest interval in is enclosing the original interval in ir
the definition also alows the intersection of two intervals to be readily 
computed
l sub 1h sub 1 inter l sub 2 h sub 2
 maxl sub 1  l sub 2 minh sub 1  h sub 2 
also and interval lh wil be empty if l  h  for example acording
to the definition above lo 31  ho 31 so 3131 is corectly computed
as being empty
intervals are introduced into logic by extending the notion of 
unification  a logical variable i can be bound to an interval i
writen i  unification of i to any other value j gives the folowing
results
if j is unbound then it is bound to the interval ji
if j is bound to the interval j then
i and j are bound to the same interval i inter j
the unification fails if i inter j is empty
a constant c is equivalent to aproxc
if j is bound to anything other than an interval the unification fails
below are some simple prolog programs and the bindings that result when
they are run asuming as usual two decimal places of acuracy
x  3141592
x3132

x  522 y  31 xy
x5332  y5331
adition is implemented by the relation adijk
which says that k is the sum of i and j
ad can be viewed as a relation on r times r times r defined
by
ad  xyzxyz mo  rxyz
given that ij and k are initialy bound to the intervals ijk 
respectively the fuly corect set of solutions with the aditional
constrain adijk is given by al triples in the set 
ad inter i times j times k  
this set is however infinite to get an efectively computable procedure
i wil aproximate the aditional constraint by binding i j and k
to smaler intervals  
so as not to exclude any posible triples the new bindings 
i prime j prime roman and k prime must obey
ad inter i times j times k subeq i prime times j prime times k prime
figure 1 ilustrates this proces of
narowing
the initial bindings are i02 j13
and k46  after aplying adijk the smalest posible bindings
are i12 j23 and k45  note that al thre intervals have ben
narowed
it can easily be sen that
i prime supeq xyz mo ad inter i times j times k 
j prime supeq yxyz mo ad inter i times j times k 
k prime supeq zxyz mo ad inter i times j times k 
if there are holes in the projected set then i prime wil be a strict
superset of the projection however i prime wil stil 
be uniquely determined by the projection  this wil be true of any
subset of r sup n not just ad
in general for
r subeq r sup n i sub 1  i sub 2    i sub n mo ir
and i prime  sub 1  i prime  sub 2    i prime  sub n mo ir
i wil write 
r inter i sub 1 times i sub 2 times  times i sub n nar 
i prime sub 1 times i prime sub 2 times  times i prime sub 
when the intervals i prime sub 1  i prime sub 2    i prime sub 
are the uniquely determined smalest intervals including al solutions

list
